<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/12/1
 * Time: 9:47
 */

namespace app\common\model;


use think\Db;
use think\Model;

class Area extends Model
{

    /**
     * 获取省份下拉列表
     */
    public static function getProvince()
    {
        return $province = Db::name('area')->where('pid', 1)->where('type', 1)->select();
    }

    /**
     * 获取市的下拉框列表
     */
    public static function getCity($pid)
    {
        return $city = Db::name('area')
            ->where('pid', $pid)->where('type', 2)->select();
    }
    /**
     * 根据省市ID 获取省市名称
     */
    public static function getNameForId($id)
    {
        return Db::name('area')->where('id', $id)->value('name');
    }
}